package mediadisplay.timeline.controls 
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;
	/**
	 * ...
	 * @author Anders Figenschow
	 */
	public class ControlButton extends ButtonBase
	{
		private var _txt:String;
		private var _tooltip:String;
		private var _color:uint;
		
		public function ControlButton(txt:String, tooltip:String, color:uint = 0xffffff) 
		{
			_color = color;
			_tooltip = tooltip;
			_txt = txt;
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			var textformat:TextFormat = new TextFormat();
			textformat.size = 12;
			textformat.color = 0x000000;
			textformat.align = TextFormatAlign.CENTER;
			
			var tf:TextField = new TextField();
			addChild(tf);
			tf.y = 10;
			tf.width = 0;
			tf.autoSize = TextFieldAutoSize.LEFT;
			tf.defaultTextFormat = textformat;
			tf.text = _txt;
			//tf.x = -tf.width / 4 - 3;
			tf.selectable = false;
			tf.mouseEnabled = false;
			
			if (_color != 0xffffff) super.changeColor(_color);
		}
		public function getTooltip():String {
			return _tooltip;
		}
	}

}